#include<bits/stdc++.h>
using namespace std;
struct stu{
	int d,v,a;
	void in(){
		cin >> d >> v >> a;
	}
}car[100005];
int p[100005];
vector<pair<int,int> > vec;
bool cmp(pair<int,int> a,pair<int,int> b){
	if(a.second==b.second)	return a.first <= b.first;
	return a.second < b.second;
}
int main(){
	freopen("detect.in","r",stdin);
	freopen("detect.out","w",stdout);
	int t; cin >> t;
	while(t--){
		vec.clear();
		int n,m,L,V; cin >> n >> m >> L >> V;
		for(int i = 1; i <= n;i++){
			cin >> car[i].d >> car[i].v >> car[i].a;
		}
		for(int i = 1; i <= m;i++){
			cin >> p[i];
		}
		sort(p+1,p+m+1);
		int cnt = 0;
		for(int i = 1;i <= n;i++){
			if(car[i].a==0||car[i].a>0&&car[i].v>V){
				if(car[i].v>V){
					cnt++;
					vec.push_back({car[i].d,L});
				}	
				continue;
			}
			int td = car[i].d+max(0,((V*V-car[i].v*car[i].v)/(2*car[i].a)));
			
			if(car[i].a>0){
				if(upper_bound(p+1,p+m+1,td)-p<=m){
					cnt++;
					vec.push_back({td+1,L});
				}
			}
			else{
				if(p[lower_bound(p+1,p+m+1,car[i].d)-p]<=td){
					cnt++; 
					vec.push_back({car[i].d,td});
				}
			}
		}
		sort(vec.begin(),vec.end(),cmp);
		cout <<cnt << " "; 
		int cnt2=m,z1=-1,z2=1;
		pair<int,int> last={0,0};
		for(auto x : vec){
			// cout << x.first << " " << x.second << endl;
			if(z1==-1){
				z1=x.second;
			}
			while(p[z2]<x.first){
				z2++;
			}
			if(p[z2]>z1){
				cnt2--;
				z1=x.second;
			}
			last = x;
		}
		cout << cnt2-1 << endl;
	}
	return 0;
}